package opera;

import book.*;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 邓大帅
 * Date: 2022-12-20
 * Time: 10:08
 */
public class BrrowOperation implements IOperation {
    public void work(BookList bookList) {
        System.out.println("借阅图书");
        System.out.println("输入你要借阅图书的名字");
        Scanner input = new Scanner(System.in);
        String name = input.nextLine();
        int currentSize = bookList.getUseSize();
        for (int i = 0; i < currentSize; i++) {
            Book temp = bookList.getBook(i);
            if(temp.getName().equals(name) && !temp.getBorrowed()) {
                temp.setBorrowed(true);
                System.out.println("借阅成功");
                return;
            }
        }
        System.out.println("借阅失败");
    }
}
